<%@ page import="java.util.*,com.release.utils.*,java.text.*,java.io.*,com.release.bean.*" %>
<%

try {
		 session = request.getSession();

			if (session.getAttribute("USER_ID") == null
					|| !((String) session.getAttribute("SESSION_ID"))
							.equals(session.getId())) {
				try {
					response.sendRedirect("LoginPage.jsp");
				} catch (IOException ioe) {
					ioe.printStackTrace();
				}
	
			} 
			else {


//System.out.println("exx id..." + (String)request.getParameter("SESSION_ID"));
//if ("exit".equals((String)request.getParameter("SESSION_ID"))) {response.sendRedirect("LoginPage.jsp"); }


/*response.setHeader("Cache-Control","no-cache");
response.setHeader("Expires", "0");
response.setHeader("Pragma", "No-cache");
response.addHeader("Cache-control", "no-store"); // tell proxy not to cache
response.addHeader("Cache-control", "max-age=0"); // stale right away*/






%>

<script>







function backtomain()
{
	//dwin = window.open("ShellScriptList.jsp","_self","width=840,height=665,scrollbars=yes,resizable=yes");

	document.mainPage.action="ShellScriptList.jsp";
	document.mainPage.submit();

}
function download(path,filename)
{
	//alert(path+"   "+filename);
	dwin = window.open("openDocument.jsp?path="+path+ "&filename="+filename,"_blank","width=600,height=400,scrollbars=yes,resizable=yes");

}

function cancelScript()
{
	document.mainPage.action="ShellScriptList.jsp";
	document.mainPage.submit();
}


</script>
<HTML>
<HEAD>
<link type="text/css" rel="stylesheet" href="styles/tracker_style.css">
<TITLE>Main Page</TITLE>
</HEAD>

<BODY>

<FORM name="mainPage" action="addEditScript.jsp" method="post">
<input type="hidden" name="added" value="">
<input type="hidden" name="days" value="">
<input type="hidden" name="edited" value="">

<TABLE width ="750" border = "0">
	<TR>
		<TD colspan="2">
			<jsp:include page="HeaderNav.jsp" flush="true" />
		</TD>
	</TR>



</TABLE>


<%  
	String SValue=null;
	String jobN=null;
	String serverN=null;
	
	ScriptVO scriptVO = null;
	String Value= null;
	String Jobedit=null;
	Jobedit = (String)request.getParameter("jobname");
	jobN=(String)request.getParameter("jobname");
	serverN=(String)request.getParameter("servername");
	System.out.println("Job"+ jobN);
	System.out.println("servername"+ serverN);
	
			
				//if ( jobN != null && serverN != null) {
					DBUtil dbutil = new DBUtil(getServletContext());				
					//arraylist = dbutil.getScriptDetails(jobN, serverN);
					  scriptVO = dbutil.getScriptDetails(jobN,serverN);
					//scriptVO = (ScriptVO) arraylist.get(0);
				//}
			
	     %>




	<% Properties property = new Properties();
    String filepath = new String();
	%> <table width=750>
	
	  <% try {
            //File propfile = new File(System.getProperty("tracker.properties.home")+"/"+"STtracker.properties");
            File propfile = new File(getServletContext().getInitParameter("tracker.properties.home")+"/"+"STtracker.properties");
			InputStream in = new FileInputStream(propfile);
            property.load(in);
            filepath = property.getProperty("DocumentPath");
            System.out.println("11111111111111111111111");
        }
        catch(Exception e) {
            System.out.println("LOADFILE>>>>>CONSTRUCTOR");
        }
	String path = filepath + Jobedit;
	 File totalpath=new  File(path) ;
	 	System.out.println("path.."+path);
	if (totalpath.isDirectory()) {
		File list[] = totalpath.listFiles();
		System.out.println("len" + list.length);
		if(list.length >0 ){
		%>
		<tr><td align=left ><label class=link><b>Document</b>  </label></td></tr>
		<%  for(int i=0;i<list.length;i++){
			String filename =list[i].getName();
			
			%> 

	<tr><td align=left ><a href="javaScript:download('<%=path%>','<%=filename%>')" class=link> <%=filename%> </td></tr>
		



<%		}
		%>
		
		
<%	 }}


%>

			
<TABLE width="750" border=0 name="tblReqs" cellpadding="0" cellspacing="1" style="BORDER:#000000 1px solid">

				
				<tr height='20' bgcolor='#000077'>
					<td class=smallfonthead colspan='6'>
						<B>
							View Script
						</B>
					</td>
				</tr>
				<tr height = 35 bgcolor=#EFEFEF>
					
					<td   class = bodyblue title="Script Name"> <LABEL><FONT size=-1><b>Job </b></FONT></LABEL></td>
					<% Value = (scriptVO != null)?scriptVO.getJob():""; 
					%>
					
					</td>	
					<td  class="bodyblue">
						
						<label><%=Value%></label>

					</td>
			
					<td class = bodyblue title="Server Name"><LABEL><FONT size=-1><b>Runs From </b></FONT></LABEL></th></td>
					</td>	

					<td   class="bodyblue">
						<%  Value = (scriptVO != null)?scriptVO.getRunsFrom():""; 
						%>
					<label><%=Value%></label>
					</td>				
				</tr>		
				


				<tr height = 35 bgcolor=#EFEFEF >
					
					<td   class = bodyblue ><LABEL><FONT size=-1><b>Feed Direction</b></FONT></LABEL></th></td>
					</td>	

					<td  class="bodyblue">
						<%  Value = (scriptVO != null)?scriptVO.getFeedDirection():""; 
				%>
					<label><%=Value%></label>
					</td>				
				
					
					<td   class = bodyblue title="Server Name"><LABEL><FONT size=-1><b>From Source </b></FONT></LABEL></td>
					<%  Value = (scriptVO != null)?scriptVO.getFromSource():""; 
					if ("Data Not Available".equals(Value)) {%>
					<td  class=bodybluescript >
						
					<label><%=Value%></label>
					</td>	
					
					<% } else { %>


					<td  class=bodybluescript >
						
					<label><%=Value%></label>
					</td>	
					<% } %>
				</tr>	
				
		

				<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue ><LABEL><FONT size=-1><b>Runs To</b></FONT></LABEL></td>
					<%  Value = (scriptVO != null)?scriptVO.getRunsTo():""; 
					
							if ("Data Not Available".equals(Value)) {

						%>

					<td  class="bodybluescript">
						
					<label><%=Value%></label>
					</td>				
				<% } else { %>
					<td  class="bodyblue">
						
					<label><%=Value%></label>
					</td>				

					<% } %>



					
					<td  class = bodyblue ><LABEL><FONT size=-1><b>Internal File Name</b></FONT></LABEL></td>
					<%  Value = (scriptVO != null)?scriptVO.getInternalFilename():""; 

						if ("Data Not Available".equals(Value)) {
						%>
						
					<td  class="bodybluescript">
						
					<label><%=Value%></label>
					</td>				
				</tr>	
				
				<% } else { %>
				<td  class="bodyblue">
					<label><%=Value%></label>
					</td>				
				</tr>	
				<% } %>

				<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue ><LABEL><FONT size=-1><b>External File Name</b></FONT></LABEL></td>
					
					<%  Value = (scriptVO != null)?scriptVO.getExternalFilename():""; 
						
						
						
						if ("Data Not Available".equals(Value)) { %>
					<td  class="bodybluescript">
						
					<label><%=Value%></label>
					</td>				
				
					<% } else { %>

					<td  class="bodyblue">
						
					<label><%=Value%></label>
					</td>				

					<% } %>


					<td  class = bodyblue title="Description"><LABEL><FONT size=-1><b>Summary
					</b></FONT></LABEL></td>
				

					<td  class="bodyblue">
						<%  Value = (scriptVO != null)?scriptVO.getSummary():""; 
						%>
					 <label><%=Value%> </label>
					
					</td>				
				</tr>		


				<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue title="Contact Person"><LABEL><FONT size=-1><b>Local Contact</b> </FONT></LABEL></th></td>
					

					<td  class="bodyblue">
						<%  Value = (scriptVO != null)?scriptVO.getLocalContact():""; 
						%>
					<label><%=Value%></label>
					</td>				
				
					<td  class = bodyblue title="Contact Person"><LABEL><FONT size=-1><b>Remote Contact</b> </FONT></LABEL></td>
					<%  Value = (scriptVO != null)?scriptVO.getRemoteContact():""; 
						if ("Data Not Available".equals(Value)) { %>

						

					<td  class="bodybluescript">
						
					<label><%=Value%></label>
					</td>	
					
					<% }  else { %>

					<td  class="bodyblue">
						
					<label><%=Value%></label>
					</td>	
					
				<% } %>

				</tr>		


				<tr height = 35 bgcolor=#EFEFEF>
					
					
					<td  class = bodyblue ><LABEL><FONT size=-1><b>Destination Biz Area</b></FONT></LABEL></td>
					<%  Value = (scriptVO != null)?scriptVO.getDestBizArea():""; 
						if ("Data Not Available".equals(Value)) {
						%>
					<td  class="bodybluescript">
						
					<label><%=Value%></label>
					</td>
					
					<% } else {%>

					<td  class="bodyblue">
						
					<label><%=Value%></label>
					</td>

					<% } %>
				
					<td  class = bodyblue ><LABEL><FONT size=-1><b>Destination Biz Contact</b></FONT></LABEL></td>
					

					<%  Value = (scriptVO != null)?scriptVO.getDestBizContact():""; 
					if ("Data Not Available".equals(Value)) {
						%>
					<td  class="bodybluescript">
						
					<label><%=Value%></label>
					</td>	
					
					<% }else{ %>

					<td  class="bodyblue">
						
					<label><%=Value%></label>
					</td>	
					<% } %>

				</tr>		




				<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue ><LABEL><FONT size=-1><b>Executed By</b></FONT></LABEL></td>
					
					<%  Value = (scriptVO != null)?scriptVO.getExecutedBy():""; 

					if ("Data Not Available".equals(Value)) {
						%>
					<td  class="bodybluescript">
						
					<label><%=Value%></label>
					</td>				
				<% }else{ %>
					<td  class="bodyblue">
						
					<label><%=Value%></label>
					</td>				
					<% } %>

					
					<td  class = bodyblue ><LABEL><FONT size=-1><b>Executes Another Script</b></FONT></LABEL></td>
					<%  Value = (scriptVO != null)?scriptVO.getExecsAnotherScript():""; 
						if ("Data Not Available".equals(Value)){
						%>

					<td class="bodybluescript">
						
					<label><%=Value%></label>
					</td>
					<% }else{ %>
					
				<td  class="bodyblue">
						
					<label><%=Value%></label>
					</td>					
						<% } %>
				</tr>		




				<tr height = 35>
				<td align ="center" colspan='4'class="bodyblueHead">Control M Specification</td></tr>






			<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue ><LABEL><FONT size=-1><b>Data Centre</b></FONT></LABEL></td>
					
					<%  Value = (scriptVO != null)?scriptVO.getDataCentre_CM():""; 
						%>
					<td  class="bodyblue">
						
					<label><%=Value%></label>
					</td>				
				
					
					<td  class = bodyblue ><LABEL><FONT size=-1><b>Application</b></FONT></LABEL></td>
					

					<td  class="bodyblue">
						<%  Value = (scriptVO != null)?scriptVO.getApplication_CM():""; 
						%>
					<label><%=Value%></label>
					</td>				
				</tr>		
				

			<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = "bodyblue"><LABEL><FONT size=-1><b>Group</b></FONT></LABEL></td>
					

					<td  class="bodyblue">
						<%  Value = (scriptVO != null)?scriptVO.getGroup_CM():""; 
						%>
					<label><%=Value%></label>
					</td>				
				
					
					<td class = bodyblue ><LABEL><FONT size=-1><b>Memember Name</b></FONT></LABEL></td>
					
					<%  Value = (scriptVO != null)?scriptVO.getMemName_CM():""; 
						if ("Data Not Available".equals(Value)){

						%>
					<td  class="bodybluescript">
						
					<label><%=Value%></label>
					</td>
					
					<% } else { %>


					<td  class="bodyblue">
						
					<label><%=Value%></label>
					</td>

					<% } %>
				</tr>		





				<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue ><LABEL><FONT size=-1><b>Node ID</b></FONT></LABEL></td>
					

					<td  class="bodyblue">
						<%  Value = (scriptVO != null)?scriptVO.getNodeID_CM():""; 
						%>
					<label><%=Value%></label>
					</td>				
				
					
					<td class = bodyblue ><LABEL><FONT size=-1><b>Owner</b></FONT></LABEL></td>
					

					<td class="bodyblue">
						<%  Value = (scriptVO != null)?scriptVO.getOwner_CM():""; System.out.println("owner" + Value);
						%>
					<label><%=Value%></label>
					</td>				
				</tr>	
				


				<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue title="Arguments to be passed"><LABEL><FONT size=-1><b>Command Line</b> </FONT></LABEL></td>
					
					<%  Value = (scriptVO != null)?scriptVO.getCommandLine_CM():""; 
						 if ("Data Not Available".equals(Value)){ %>
					<td  class="bodybluescript">
						
					<label><%=Value%></label>
					</td>				
				<% } else { %>

				<td  class="bodyblue">
						
					<label><%=Value%></label>
					</td>	

					<% } %>

					<td  class = bodyblue ><LABEL><FONT size=-1><b>Days<b></FONT></LABEL></td>
					

					<td  class="bodyblue">
						<%  Value = (scriptVO != null)?scriptVO.getDays_CM():""; 
						 SValue=Value.substring(1,Value.length());

						System.out.println("daysss" + SValue);
						%>
					<label><%= SValue %></label>
					</td>				
				</tr>		



			<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue ><LABEL><FONT size=-1><b>Dependencies IN</b></FONT></LABEL></th></td>
					

					<td  class="bodyblue">
						<%  Value = (scriptVO != null)?scriptVO.getDependenciesIN_CM():""; 
						%>
					<label><%=Value%></label>
					</td>				
				
					<td  class = bodyblue ><LABEL><FONT size=-1><b>Dependencies OUT<b></FONT></LABEL></th></td>
					

					<td  class="bodyblue">
						<%  Value = (scriptVO != null)?scriptVO.getDependenciesOUT_CM():""; 
						%>
					<label><%=Value%></label>
					</td>				
				</tr>		


				<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue ><LABEL><FONT size=-1><b>Run Time<b></FONT></LABEL></td>
					
					<%  Value = (scriptVO != null)?scriptVO.getRunTime_CM():"";
					
					if ("Data Not Available".equals(Value)){
						%>
					<td  class="bodybluescript">
						
					<label><%=Value%></label>
					</td>				
					<% } else { %>
					

					<td  class="bodyblue">
						
					<label><%=Value%></label>
					</td>	
					
					<% } %>

					<td  class = bodyblue title="Other Details"><LABEL><FONT size=-1><b>Miscellaneous</b>:</FONT></LABEL></td>
					
					<%  Value = (scriptVO != null)?scriptVO.getMisc_CM():""; 
							if ("Data Not Available".equals(Value)){
						%>
					<td  class="bodybluescript">
						
					<label><%=Value%></label>
					</td>	
					<% } else { %>
				
					<td  class="bodyblue">
						
					<label><%=Value%></label>
					</td>	
						<% } %>
				</tr>		





















				

			</TABLE>



			<table width ="750">
			<tr><td align = right><INPUT type="button" value="Back to List" onclick="javascript:backtomain()" class='whitebutton'> </td></tr>
		




<% }

}
catch(Exception e) {
				e.printStackTrace();
		}
%>

</FORM>
</BODY>
</HTML> 

